<?php
include 'publics.php';
@header("content-Type: text/html; charset=utf-8");
if (!empty($_POST)) {
    $name = $_POST['name'];
    $pass = $_POST['pass'];
    $sqll ="select username from table1 where username = '".$name."'" ;
    $mysql = new Mysql();
    $uuu = $mysql->select_one($sqll);
    if (empty($uuu)){
        $sql = "insert into table1 (username,userpass) values ('".$name."','".$pass."')";
        $date =array(
            'username' => $_POST['name'],
            'userpass' => $_POST['password']
        );
        $user = $mysql->insert($date,'table1');
        if ($user == true) {
            echo '<script type="text/javascript">';
            echo 'window.location.href="Success.php";';
            echo '</script>';
        }
    }else{
        echo '<script type="text/javascript">';
        echo 'window.location.href="zxc.php";';
        echo '</script>';
    }
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>注册</title>
    <script src="js/jquery.min.js"></script>
</head>

<style type="text/css">
    .dl{
        position: relative;
    }
    .dj{
        box-shadow: 10px 10px 10px #ccc;
        width: 400px;
        height: 400px;
        position:absolute;
        left: 40%;
        top:25%;
    }
    .dj input{
        margin-top: 40px;
    }
</style>
<body>
<form action="" method="post" class="dj">
    <div class="dl">
        账号：<input type="text" value="" placeholder="请输入账号" class="name" name="name">
        <br>
        密码：<input type="text" value="" placeholder="请输入密码" class="phone" name="password">
        <br>
        确认密码：<input type="text" value="" placeholder="确认密码" class="pass" name="pass">
        <br>
        <input type="submit"  value="注册" onclick="return cit()">
        <a href="sign.php" style="float: right;padding-top: 190px;">点击进入登录界面</a>
    </div>
</form>
<script type="text/javascript">
    function cit(){
        var name = $('.name').val();
        var phone = $('.phone').val();
        var  password =$('.pass').val();

        if( name == ''){
            alert('请输入账号');
            return false;
        }
        if( phone == ''){
            alert('请输入密码');
            return false;
        }
        if ( phone != password){
            alert('两次输入的密码不一致');
            return false;
        }
    }
</script>
</body>
</html>



